package cn.mazexal.exambg.controller;

import cn.mazexal.exambg.common.models.PagedQry;
import cn.mazexal.exambg.common.models.PagedResponse;
import cn.mazexal.exambg.common.models.SingleResponse;
import cn.mazexal.exambg.models.qry.IDQry;
import cn.mazexal.exambg.models.qry.MaterialQry;
import cn.mazexal.exambg.models.qry.QuestionQry;
import cn.mazexal.exambg.models.vo.ExamQuestionMaterialsVO;
import cn.mazexal.exambg.models.vo.ExamQuestionVO;
import cn.mazexal.exambg.models.vo.ReportQuestionVO;
import cn.mazexal.exambg.services.QuestionService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: Mazexal
 * Date: 2025/5/13
 */
@RestController
@RequestMapping("/question")
public class QuestionController {
    @Resource
    private QuestionService questionService;

    @PostMapping("/getQuestionList")
    public PagedResponse<ExamQuestionVO> getQuestionList(@RequestBody QuestionQry qry) {
        return PagedResponse.of(questionService.getQuestionList(qry));
    }

    @PostMapping("/getQuestion")
    public SingleResponse<ExamQuestionVO> getQuestion(@RequestBody IDQry qry) {
        ExamQuestionVO question = questionService.getQuestion(qry.getId());
        return SingleResponse.of(question);
    }

    @PostMapping("/addQuestion")
    public SingleResponse<Boolean> addQuestion(@RequestBody ExamQuestionVO examQuestionVO) {
        return SingleResponse.of(questionService.addQuestion(examQuestionVO));
    }

    @PostMapping("/updateQuestion")
    public SingleResponse<Boolean> updateQuestion(@RequestBody ExamQuestionVO examQuestionVO) {
        return SingleResponse.of(questionService.updateQuestion(examQuestionVO));
    }

    @PostMapping("/deleteQuestion")
    public SingleResponse<Boolean> deleteQuestion(@RequestBody IDQry id) {
        return SingleResponse.of(questionService.deleteQuestion(id.getId()));
    }

    @PostMapping("/addMaterial")
    public SingleResponse<Boolean> addMaterial(@RequestBody ExamQuestionMaterialsVO materialVO) {
        return SingleResponse.of(questionService.addMaterial(materialVO));
    }

    @PostMapping("/updateMaterial")
    public SingleResponse<Boolean> updateMaterial(@RequestBody ExamQuestionMaterialsVO materialVO) {
        return SingleResponse.of(questionService.updateMaterial(materialVO));
    }

    @PostMapping("/deleteMaterial")
    public SingleResponse<Boolean> deleteMaterial(@RequestBody IDQry idQry) {
        return SingleResponse.of(questionService.deleteMaterial(idQry.getId()));
    }

    @PostMapping("/getMaterialList")
    public PagedResponse<ExamQuestionMaterialsVO> getMaterialList(@RequestBody MaterialQry qry) {
        return PagedResponse.of(questionService.getMaterialList(qry));
    }


    @PostMapping("/getReportQuestionList")
    public PagedResponse<ReportQuestionVO> getReportQuestionList(@RequestBody PagedQry qry) {
        return PagedResponse.of(questionService.getReportQuestionList(qry));
    }

    @PostMapping("/handleReportQuestion")
    public SingleResponse<Boolean> handleReportQuestion(@RequestBody IDQry idQry) {
        return SingleResponse.of(questionService.handleReportQuestion(idQry.getId()));
    }
}
